# Maintainer: David Runge <dvzrv@archlinux.org>

_name=atpublic
pkgname=python-atpublic
pkgver=3.1.1
pkgrel=2
pkgdesc="@public decorator for Python"
arch=(any)
url="https://gitlab.com/warsaw/public"
license=(Apache)
depends=(python)
makedepends=(python-build python-installer python-pdm-pep517)
checkdepends=(python-pytest python-sybil)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha512sums=('b34dbb236717b2017de95aa79226f0138e77814a4041e26e98f50db8f8521d81b60f9998aed719e1e1f2ee29a7c590170725e12a54260900ce9819ea3a623dac')
b2sums=('a83bfed40b5073c9aba92e367b9627a86eecb297332631222f86f0cea0f10d6fde8ffd5cbef1e3bd1f9005c1cae614268867e652e33d1bee4556e2084fb8952c')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  # install to temporary location, as importlib is used
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="test_dir/$_site_packages:$PYTHONPATH"
  pytest -vv -c /dev/null
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 README.rst -t "$pkgdir/usr/share/doc/$pkgname/"
}
